'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;
  const { sign, auth } = app.middlewares;
  router.get('/', controller.home.index);
  router.post('/login', sign, controller.login.index);
  router.post('/upload', sign, auth, controller.upload.index);
  router.get('/user', sign, auth, controller.user.show); // 查询用户信息
  router.post('/user/', sign, auth, controller.user.update); // 修改密码

  router.get('/blog', sign, auth, controller.blog.index);
  router.get('/blog/:id', sign, auth, controller.blog.show);
  router.post('/blog', sign, auth, controller.blog.create);
  router.post('/blog/toggleStatus', sign, auth, controller.blog.toggleStatus);
  router.post('/blog/:id', sign, auth, controller.blog.update);
  router.delete('/blog/:id', sign, auth, controller.blog.destroy);

  // router.get('/migration', sign, controller.migration.index);

  router.get(/static(.*)\.(png|jpg|jpeg|gif)/, controller.static.index);
};
